package com.zj.core.ui

import android.graphics.Color
import android.os.Build
import android.support.annotation.RequiresApi
import android.support.constraint.ConstraintLayout
import android.view.View
import android.view.ViewGroup
import com.zj.core.R
import org.jetbrains.anko.*
import org.jetbrains.anko.constraint.layout.constraintLayout
import org.jetbrains.anko.constraint.layout.guideline
import org.jetbrains.anko.constraint.layout.matchConstraint

class ListFormItemUi: AnkoComponent<ViewGroup> {
    @RequiresApi(Build.VERSION_CODES.M)
    override fun createView(ui: AnkoContext<ViewGroup>): View =with(ui){
        constraintLayout {
            id= R.id.record_item_parent_view

            lparams(width= matchParent,height =dip(40)){
                leftMargin=dip(10)
                rightMargin=dip(10)
            }

            guideline {
                id = R.id.guideline_v_20
            }.lparams(width = wrapContent, height = matchConstraint) {
                orientation = ConstraintLayout.LayoutParams.VERTICAL
                guidePercent = 0.2F
            }

            imageView{
                id= R.id.record_item_form_img
                setImageDrawable(resources.getDrawable(R.drawable.circular_tag2_textview))
            }.lparams(width=0,height = wrapContent){
                topToTop= ConstraintLayout.LayoutParams.PARENT_ID
                bottomToBottom= ConstraintLayout.LayoutParams.PARENT_ID
                leftToLeft= ConstraintLayout.LayoutParams.PARENT_ID
                rightToLeft= R.id.guideline_v_20
            }

            textView{
                textSize= 15F
                textColor= Color.BLACK
                id= R.id.record_item_form_value
            }.lparams(width=0,height = wrapContent){
                topToTop= ConstraintLayout.LayoutParams.PARENT_ID
                bottomToBottom= ConstraintLayout.LayoutParams.PARENT_ID
                rightToRight=ConstraintLayout.LayoutParams.PARENT_ID
                leftToRight= R.id.guideline_v_20
            }
        }
    }
}